//
// Created by Arikes on 9/25/21.
//

#ifndef DESIGNERMODE_INVOKER_H
#define DESIGNERMODE_INVOKER_H

#include "Command.h"
namespace CommandMode
{
    class Invoker
    {
    public:
        Invoker(Command* cmd):_cmd(cmd)
        {
        }

        void setCommand(Command* cmd)
        {
            _cmd = cmd;
        }

        void call()
        {
            std::cout<<"调用者执行命令command..."<<std::endl;
            if (nullptr != _cmd)
                _cmd->execute();
        }

    private:
        Command* _cmd = nullptr;
    };
}

#endif //DESIGNERMODE_INVOKER_H
//CommandMode::Invoker* invoker = new CommandMode::Invoker(nullptr);
//invoker->setCommand(new CommandMode::ConcreteCommand);
//invoker->call();